package com.meyoung.day3;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class JStest {
    WebDriver driver;
    @BeforeMethod
    public void openchromeTest01() {
        //设置chromedriver路径
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\cll520\\IdeaProjects\\selenium11\\drivers\\chromedriver.exe");
        //实例化Chromedriver
        driver = new ChromeDriver();
    }
    @Test
    public void exJS() throws InterruptedException {
        driver.get("http://www.baidu.com");
        JavascriptExecutor js =(JavascriptExecutor)driver;
        js.executeScript("document.getElementById(\"kw\").setAttribute(\"value\",\"webdriver\")");

        Thread.sleep(5000);

    }
    @AfterMethod
    public void quiteCase(){
        driver.quit();
    }
}
